<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-for</title>
</head>

<body>
    <div>
        <h3>小黑的书架</h3>
        <ul>
            <li v-for="v in arr">
                <span>{{v.name}}</span>
                <span>{{v.author}}</span>
                <button @click="del(v.id)">删除</button>
            </li>
        </ul>
    </div>
    <script src="./js/dev/vue.js"></script>
    <script>
        const app = new Vue({
            el: 'div',
            data: {
                arr: [
                    {
                        id: 1,
                        name: '《红楼梦》',
                        author: '曹雪芹',
                    }, {
                        id: 2,
                        name: '《西游记》',
                        author: '吴承恩',
                    }, {
                        id: 3,
                        name: '《三国演义》',
                        author: '罗贯中',
                    }, {
                        id: 4,
                        name: '《水浒传》',
                        author: '施耐庵',
                    },
                ]
            },
            methods: {
                del(id) {
                    console.log(id);
                    this.arr = this.arr.filter(e => e.id !== id)
                }
            }
        })
    </script>
</body>

</html>